package com.fjt.book_pay.dao;

import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import com.fjt.book_pay.pojo.Bank;


public interface BankDao {
	@Results({
		@Result(property = "money", column = "money"),
		@Result(property = "password", column = "password"),
		@Result(property = "bank_number", column = "bank_number")}
	)
	
	@Select("Select * from bank where bank_number=#{bank_number}")
	public Bank findBankAccountById(Bank bank);
	
	@Select("Select * from bank where bank_number=#{bank_number} and password=#{password}")
	public Bank validateUser(Bank bank);
	
	
	@Update("update bank set money=money+#{money} where bank_number=#{bank_number}")
	public boolean addBankMoney(@Param("bank_number") int bank_number,@Param("money") int money);
	
	@Update("update bank set money=money-#{money} where bank_number=#{bank_number} and password=#{password}")
	public boolean subBankMoney(@Param("bank_number") int bank_number,@Param("password")String password,@Param("money") int money);
			
	@Select("select money from bank where bank_number=#{bank_number}")
	public int checkmoney(Bank bank);
	
}
